﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace ECSS.Winform
{
    public partial class PayFinished : Form
    {
        OrderControllerWCF wcf;

        public PayFinished()
        {
            InitializeComponent();
            wcf = new OrderControllerWCF();
        }

        private void btnNotifPayFinish_Click(object sender, EventArgs e)
        {
            this.Enabled = false;

            StringBuilder sb = new StringBuilder();

            if (!string.IsNullOrEmpty(txtOrderIDs.Text.Trim())
                && txtOrderIDs.Lines.Count() > 0)
            {
                for (int i = 0; i < txtOrderIDs.Lines.Count(); i++)
                {
                    string orderid = txtOrderIDs.Lines[i];
                    if (string.IsNullOrEmpty(orderid)) continue;

                    try
                    {
                        bool flag = false;
                        wcf.OrderPaymentFinishedNotify(orderid, DateTime.Now, true, out flag, out flag);
                    }
                    catch (Exception ex)
                    {
                        sb.Append(ex.Message + "\r\n");
                    }

                    Thread.Sleep(300);
                }
            }
            if (!string.IsNullOrEmpty(sb.ToString()))
                MessageBox.Show(sb.ToString());

            this.Enabled = true;
        }
    }
}
